//
//  MainDefaulSearctVC_SearchV.m
//  ZITHER
//
//  Created by weixin on 2018/11/19.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "MainDefaulSearctVC_SearchV.h"

@implementation MainDefaulSearctVC_SearchV

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
        [self masonry];
    }
    return self;
}

-(void)setUI{
    
    /* MARK: ================= 返回按钮 =================*/

    QMUIButton *btn1 = [[QMUIButton alloc]initWithFrame:CGRectMake(0, kStatusBarHeight2+10,40, 40)];
    [btn1 setImage:[UIImage imageNamed:@"common_back"] forState:UIControlStateNormal];
    [self addSubview:btn1];
    @weakify(self);
    [[btn1 rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self);
        [self.getNav popViewControllerAnimated:YES];
    }];
    
    [self addSubview:self.leb];
    
    [self addSubview:self.btn2];
    
    [self addSubview:self.btn3];
    
    [self addSubview:self.btn];
    
    self.btn.centerY = self.btn2.centerY;
}


-(void)masonry{
    
    [self.btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(60);
        make.right.equalTo(self).offset(-60);
        make.top.equalTo(self).offset(kStatusBarHeight2+14);
        make.height.mas_equalTo(30);
    }];
    
    [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.btn2.mas_centerY).offset(0);
        make.right.equalTo(self).offset(-17);
        make.height.width.mas_equalTo(16);
    }];
    
    [self.leb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-15);
    }];
    
    [self.btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(28);
        make.bottom.equalTo(self.mas_bottom).offset(-17);
        make.width.mas_equalTo(100);
//        make.height.width.mas_equalTo(20);
    }];
    
    
    
}



-(QMUIButton *)btn{
    if (!_btn) {
        //8展开选择器
        _btn = [[QMUIButton alloc]initWithFrame:CGRectMake(kScreenW-60, kStatusBarHeight,40, 40)];
        [_btn setImage:[UIImage imageNamed:@"search_btn_filter"] forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn.backgroundColor = [UIColor randomColor];
    }
    return _btn;
}

-(BaseBtn *)btn3
{
    if (!_btn3) {
        //排序按钮
        _btn3 = [[BaseBtn alloc]initWithFrame:CGRectMake(kScreenW-100, kStatusBarHeight,100, 50)];
//        _btn3.backgroundColor = [UIColor redColor];
        [_btn3 setTitle:@" 二手价 " forState:UIControlStateNormal];
        [_btn3 setTitle:@" 二手价 " forState:UIControlStateSelected];
        [_btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [_btn3 setTitleColor:baseColorTheme forState:UIControlStateSelected];
        [_btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        [_btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        
        
        _btn3.tag = 300;
        _btn3.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        
        [_btn3 sizeToFit];

        _btn3.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
        _btn3.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -70);
        
        
        @weakify(self);

    }
    return _btn3;
}
//nav_btn_ascend nav_btn_descend
-(void)chageBtn{
    
    if (self.btn3.selected) {
        [self.btn3 setTitle:@" 二手价 " forState:UIControlStateNormal];
        [self.btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_ascend"] forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_ascend"] forState:UIControlStateSelected];

//        self.btn3.enabled = NO;
        //        self.trash .backgroundColor = [UIColor redColor];
//        [self.btn3 mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.equalTo(self.price.mas_centerY).offset(0);
//            make.right.equalTo(self).offset(-15);
//            make.width.mas_equalTo(100);
//            make.height.mas_equalTo(15);
//        }];
        
    }else{
        [self.btn3 setTitle:@" 二手价 " forState:UIControlStateNormal];
        [self.btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateSelected];
    }
}



-(QMUIButton *)btn2{
    if (!_btn2) {
        _btn2 = [[QMUIButton alloc]initWithFrame:CGRectMake(20,kStatusBarHeight+80, kScreenW-100, 35)];
        [_btn2 setTitle:@"  关键字" forState:UIControlStateNormal];
        [_btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _btn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [_btn2 setCornerRadiusWithRadius:8 isMasks:YES];
        [_btn2 setBorderWithColor:[UIColor blackColor] width:1];
        [_btn2 setImage:[UIImage imageNamed:@"搜索结果_搜索"] forState:UIControlStateNormal];
        _btn2.imageEdgeInsets = UIEdgeInsetsMake(0,10,0,0);
        _btn2.titleEdgeInsets = UIEdgeInsetsMake(0,10,0,0);

    
    }
    return _btn2;
}

-(QMUILabel *)leb{
    if (!_leb) {
        _leb = [[QMUILabel alloc]initWithFrame:CGRectMake(20,kStatusBarHeight+35, kScreenW-20, 40)];
        _leb.text = @"0个筛选条件结果";
        _leb.font = [UIFont systemFontOfSize:18];
        _leb.textColor = [UIColor blackColor];
    }
    return _leb;
}

@end
